<style scoped>
.div_main{
  position: relative !important;
  background: transparent;
  padding-top: 10px;
  padding-bottom: 10px;
  padding-left: 10px;
  padding-right: 10px;
  overflow-y: scroll;
  height:calc(100% - 40px);
  /*border: 1px red solid;*/
}
.div_main::-webkit-scrollbar { width: 0; height: 0; }

.main_cell_gruop {
  background-color: transparent;
}
.main_cell_gruop .van-cell{
  height: 90px;
  border-radius: 10px;
  margin-bottom: 10px;
  box-shadow: 0px 0px 2px rgba(0,37,57,0.2);
}

.div_center_card{
  position: relative;
  top: 40px;
  left: 0px;
  width: calc(100% - 0px);
  overflow-y: scroll;
  border-radius: 10px;
  background-color: #ffffff;
  box-shadow: 0px 0px 2px rgba(0,37,57,0.2);
}
</style>
<template>
  <div class="div_main">
    <div v-show="!taskEditShow" class="main_cell_gruop"
         v-loading="taskListLoading">
      <van-cell v-for="item in taskList" @click="showTaskEdit(item)" style="padding-right: 0px;">
        <template #title>
          <div style="margin-top: 14px;">
            <div style="float: left;width: 60px;">
              <van-image width="40" height="40"
                         src="/images/mob-icon-box-01.svg" />
              <van-image width="16" height="16"
                         src="/images/mob-icon-task.svg"
                         style="position: absolute;left:28px;top:35px;"/>
            </div>
            <div style="float: left;width: calc(100% - 60px);">
              <div style="font-size: 14px;">
                <span style="color: #505968;">{{ item.n_title_str }}</span>
              </div>
              <div style="font-size: 12px;">
                <span style="color: #999999;">{{ item.flow_title + ' - '+ item.sys_code_key }}</span>
              </div>
            </div>
          </div>
        </template>
      </van-cell>
    </div>
    <div v-show="taskEditShow"
         style="position: relative;left:0px;top:20px;font-size: 24px;color: #ffffff;" >
      <van-icon name="arrow-left" style="float: left;" @click="taskEditShow=false" />
    </div>
    <div v-show="taskEditShow" class="div_center_card">
      <elm-mob-flow-secform v-if="taskEditShow && taskEditData.type=='flow_task' && taskEditData.url==node_url_flowsec_form"
                            :flow_code="taskEditData.flow_code" :data_id="taskEditData.id"
                            :nodeins_id="taskEditData.nodeins_id" :page_type="taskEditPageType"
                            :pb_flag="taskEditPbFlag" @push_back_show="pushBackShow"
                            @after_submit="taskSubmited"></elm-mob-flow-secform>
      <elm-mob-task-rwzp v-if="taskEditShow && taskEditData.type=='yw_task' && taskEditData.url==task_url_rwzp"
                         :task_id="taskEditData.id" @after_submit="taskSubmited"></elm-mob-task-rwzp>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      loading: false,

      taskListLoading:true,
      taskList:[],
      taskEditShow:false,
      taskEditPageType:'',
      taskEditData: {},
      taskEditPbFlag:'no',

      node_url_flowsec_form:'/system/flow/one_road_flowsec_form_s',
      task_url_rwzp:'/business/pmis/rwzp_edit',
    }
  },
  mounted() {
    this.v_getTask();
  },
  methods: {
    async v_getTask(){
      this.taskListLoading = true;
      let taskList = [];

      let pData = {'pageNum':1,'pageSize':50};
      let taskData = await elm.post('/system/login/flow/GetUserTaskRunning', pData);
      taskList = taskData.pagedata;
      for(let i=0;i<taskList.length;i++){
        let item = taskList[i];
        item['n_title_str'] = item.title==null?'任务':item.title;
        item.n_title_str = item.n_title_str+'  '+item.create_time;
      }
      //console.log(JSON.stringify(taskList));

      this.taskList = taskList;
      this.taskListLoading = false;
    },
    showTaskEdit:function(data){
      this.taskEditPageType = 'edit';
      this.taskEditData = data;
      this.taskEditShow = true;
    },
    taskSubmited:function(){
      this.taskEditShow = false;
      this.taskEditData = {};
      this.v_getTask();
    },
    pushBackShow:function (){
      this.taskEditPbFlag = 'yes';
    },

    em: function (s) {
      if (s == null || s == '') { return true; }
      else { return false; }
    },

  }
}
</script>
